package 设计模式.单例;


import java.util.concurrent.atomic.AtomicLong;

/**
 * 饿汉式
 * @version 1.00
 * @Author lt
 * @Date 2021/6/17 17:18
 **/
public class IdGenerator {
    private AtomicLong id = new AtomicLong(0);
    private static final IdGenerator instance = new IdGenerator();
    private IdGenerator(){}
    public static IdGenerator getInstance(){
        return instance;
    }
    public long getId(){
        return id.incrementAndGet();
    }
}
